/**
 * Bestpay.com.cn Inc.
 * Copyright (c) 2011-2019 All Rights Reserved.
 */
package com.yangjicong.o2o.studey.base.common.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;

/**
 * @author yuhao
 * @version Id: SmartRestaurantErrorEnun.java, v 0.1 2019/10/12 10:52 yuhao Exp $$
 */
@Getter
@AllArgsConstructor
public enum SmartRestaurantErrorEnum {
    /**
     * 查询结果为空
     */
    EMPTY("EMPTY", "查询结果为空"),
    RESTAURANT_NO_BEING_USED("RESTAURANT_NO_BEING_USED", "食堂存在员工，不能删除"),
    RESTAURANT_NO_BEING_ROLED("RESTAURANT_NO_BEING_ROLED", "食堂存在角色，不能删除"),
    RESTAURANT_NO_NOT_EXIST("RESTAURANT_NO_NOT_EXIST","食堂编码错误"),
    RESTAURANT_NAME_NOT_MATCH("RESTAURANT_NAME_NOT_MATCH","食堂名称不匹配"),
    RESTAURANT_ROLE_ID_NOT_EXIST("RESTAURANT_ROLE_ID_NOT_EXIST","食堂角色编码错误"),
    RESTAURANT_NO_EXIST("RESTAURANT_NO_EXIST", "商户尚未注册食堂"),
    RESTAURANT_ROLE_NO_EXIST("RESTAURANT_ROLE_NO_EXIST","角色不存在"),
    RESTAURANT_USER_NO_EXIST("RESTAURANT_USER_NO_EXIST","用户不存在"),
    RESTAURANT_NO_NOT_MATCH("RESTAURANT_NO_NOT_MATCH","食堂编码与员工信息不匹配"),
    RESTAURANT_USER_ID_NOT_EXIST("RESTAURANT_USER_ID_NOT_EXIST","食堂员工id错误"),
    RESTAURANT_ROLE_ID_BEING_USED("RESTAURANT_ROLE_ID_BEING_USED","角色被占用，不能删除"),
    RESTAURANT_ROLE_ID_NOT_MATCH_NO("RESTAURANT_ROLE_ID_NOT_MATCH_NO","角色不属于本食堂"),
    RESTAURANT_AGGREEMENT_ID_NOT_MATCH("RESTAURANT_AGGREEMENT_ID_NOT_MATCH","协议id与用户信息不匹配"),
    RESTAURANT_FACE_ID_NOT_MATCH("RESTAURANT_FACE_ID_NOT_MATCH","人脸id与用户信息不匹配"),
    UNSIGNED_DEDUCATION_AGGREEMENT("UNSIGNED_DEDUCATION_AGGREEMENT","未签约代扣产品"),
    RESTAURANT_NAME_EXIST("RESTAURANT_NAME_EXIST","食堂名称已存在"),
    RESTAURANT_ROLE_NAME_EXIST("RESTAURANT_ROLE_NAME_EXIST","食堂角色名称已存在"),
    MERCHANT_NO_EXIST("MERCHANT_NO_EXIST","商户号已被使用"),
    FACE_ID_EXIST("FACE_ID_EXIST","食堂已录入过该员工信息"),
    MERCHANT_NOT_SIGNED_PRODUCT("MERCHANT_NOT_SIGNED_PRODUCT","商户未签约免密代扣产品"),
    USER_GRADE_NOT_ENOUGH("USER_GRADE_NOT_ENOUGH","翼支付账户至少需要二星用户才可绑定"),
    AGREEMENT_IS_EXIST("AGREEMENT_IS_EXIST","翼支付账户已与其他用户绑定"),
    PHONE_NO_EXIST("PHONE_NO_EXIST","翼支付账户不存在"),
    AGREEMENT_SAVE_FAIL("AGREEMENT_SAVE_FAIL","协议存储失败"),
    DFSPATH_IS_EMPTY("DFSPATH_IS_EMPTY","dfs路径为空"),
    RESTAURANT_ROLE_IS_EXIST("RESTAURANT_ROLE_IS_EXIST","食堂角色已存在"),
    RESTAURANT_ROLE_VALIDITY_ERROR("RESTAURANT_ROLE_VALIDITY_ERROR","用户角色未在有效期内"),
    RESTAURANT_ROLE_ADD_ERROE("RESTAURANT_ROLE_ADD_ERROE","食堂角色新增失败"),
    RESTAURANT_ROLE_COST_NUMBER_IS_ERROR("RESTAURANT_ROLE_COST_NUMBER_IS_ERROR","食堂角色用餐次数及金额配置不完整"),
    RESTAURANT_WORK_TIME_IS_OVERLAP("RESTAURANT_WORK_TIME_IS_OVERLAP","食堂工作时间重叠"),

    /**
     * 不可编辑该食堂信息
     */
    LIMIT_EDIT_RESTAURANT("LIMIT_EDIT_RESTAURANT","不可编辑该食堂信息"),

    /**
     * 请求系统非法
     */
    REQUEST_SYSTEM_ILLEGAL("REQUEST_SYSTEM_ILLEGAL","请求系统非法")
    ;

    private String errorCode;
    private String errorDes;

    /**
     * 查询当前枚举值是否存在
     * @param code  编码
     * @return
     */
    public static String explain(String code) {
        if(StringUtils.isNotEmpty(code)) {
            for (SmartRestaurantErrorEnum smartRestaurantErrorEnum : SmartRestaurantErrorEnum.values()) {
                if(smartRestaurantErrorEnum.errorCode.equalsIgnoreCase(code)) {
                    return smartRestaurantErrorEnum.errorDes;
                }
            }
        }
        return null;
    }
}